Skip to content

Conversation

@ozhanozen
Copy link
Contributor

Description

Due to previous changes, the rl_games workflow's log_root_path is no longer the absolute path if the pbt option is not used, causing further issues. This PR fixes this by making it an absolute path again.

Fixes #3530

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Screenshots

Before:

log_root_path = os.path.join("logs", "rl_games", config_name)
if "pbt" in agent_cfg:
if agent_cfg["pbt"]["directory"] == ".":
log_root_path = os.path.abspath(log_root_path)
else:
log_root_path = os.path.join(agent_cfg["pbt"]["directory"], log_root_path)

After:

log_root_path = os.path.join("logs", "rl_games", config_name)
if "pbt" in agent_cfg and agent_cfg["pbt"]["directory"] != ".":
    log_root_path = os.path.join(agent_cfg["pbt"]["directory"], log_root_path)
else:
    log_root_path = os.path.abspath(log_root_path)

Note

While this fixes the path to be absolute when pbt is not used, I am not sure if

log_root_path = os.path.join(agent_cfg["pbt"]["directory"], log_root_path)

is correct or absolute, as I do not use pbt. Should it not be something like the following?

log_root_path = os.path.abspath(os.path.join(log_root_path, agent_cfg["pbt"]["directory"]))

I would appreciate any feedback on this.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

Copy link
Collaborator

@garylvov garylvov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ozhanozen
Copy link
Contributor Author

Hi @ooctipus, would love to get your opinion before merging on the line:
log_root_path = os.path.join(agent_cfg["pbt"]["directory"], log_root_path)
so we are sure that the pbt log directory is also correct.

@ooctipus
Copy link
Collaborator

sorry for the late response, yes I believe this is correct!

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

This PR fixes a bug where log_root_path remained a relative path when PBT (Population-Based Training) is not used, which broke functionality in Ray and potentially other systems that expect absolute paths.

Key Changes

  • Restructured the conditional logic to ensure os.path.abspath() is called when PBT is not enabled or when PBT directory is "."
  • Successfully addresses the main issue reported in #3530

Issues Found

  • The author's concern about PBT path handling is valid: when agent_cfg["pbt"]["directory"] is set to a relative path or empty string (the default in PbtCfg), the resulting log_root_path will still be relative
  • Added debug print statement at line 159 that may need removal

Confidence Score: 4/5

  • This PR is safe to merge with one logical issue that should be addressed
  • The PR successfully fixes the primary bug (non-absolute path when PBT is disabled), but has an edge case where PBT with relative/empty directory still produces relative paths. The fix is simple and the author already identified this concern in the PR description.
  • Pay attention to scripts/reinforcement_learning/rl_games/train.py lines 141-144 for the PBT path handling edge case

Important Files Changed

File Analysis

Filename Score Overview
scripts/reinforcement_learning/rl_games/train.py 4/5 Fixes log_root_path to be absolute when PBT is not used, but PBT path handling still has edge cases with relative or empty directory values

Sequence Diagram

sequenceDiagram
    participant Main as main()
    participant PathLogic as Path Logic
    participant Config as agent_cfg
    participant FileSystem as File System
    
    Main->>Config: Read config_name
    Main->>PathLogic: Create log_root_path = "logs/rl_games/{config_name}"
    
    alt PBT enabled AND directory != "."
        PathLogic->>Config: Get agent_cfg["pbt"]["directory"]
        PathLogic->>PathLogic: os.path.join(pbt_dir, log_root_path)
        Note over PathLogic: May be relative if pbt_dir is relative/empty!
    else No PBT OR directory == "."
        PathLogic->>PathLogic: os.path.abspath(log_root_path)
        Note over PathLogic: Now absolute (fixes the bug)
    end
    
    PathLogic->>Main: Return log_root_path
    Main->>FileSystem: Create directories with log_root_path
    Main->>FileSystem: dump_yaml() to log_root_path
    Main->>Config: Set train_dir = log_root_path
Loading

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

Fixes the missing else clause that caused log_root_path to remain relative when PBT is not used, restoring the absolute path behavior that Ray and other integrations depend on.

Key changes:

  • Restructured the PBT directory check to use a single if-else statement
  • Added os.path.abspath() call in the else branch for non-PBT scenarios
  • Fixed the immediate issue reported in #3530

Remaining issues:

  • When PBT is enabled with a relative or empty directory value (default is ""), log_root_path will still be relative, which could cause the same issue
  • The existing comment correctly identifies this concern and suggests wrapping the PBT case with os.path.abspath() as well
  • Added a debug print statement on line 159 that should be removed

Confidence Score: 3/5

  • Safe to merge but incomplete - fixes the immediate issue while leaving PBT edge case unresolved
  • The PR successfully addresses the reported bug for non-PBT scenarios, but the PBT path handling still has the same relative path issue when agent_cfg["pbt"]["directory"] is relative or empty (default is ""). The existing reviewer comment correctly identifies this and provides a solution. Additionally, a debug print statement was added that should be removed.
  • scripts/reinforcement_learning/rl_games/train.py requires attention to address the PBT relative path issue and remove debug print

Important Files Changed

File Analysis

Filename Score Overview
scripts/reinforcement_learning/rl_games/train.py 2/5 Fixes missing else clause for absolute path conversion, but PBT path handling still has issues with relative paths

Sequence Diagram

sequenceDiagram
    participant Main as main()
    participant Config as agent_cfg
    participant FS as File System
    participant RLGames as RL-Games Runner
    
    Main->>Config: Get config_name
    Main->>Main: Create relative path<br/>"logs/rl_games/{config_name}"
    
    alt PBT enabled AND directory != "."
        Main->>Config: Get pbt["directory"]
        Main->>Main: os.path.join(pbt_dir, log_root_path)<br/>(may still be relative!)
    else PBT disabled OR directory == "."
        Main->>Main: os.path.abspath(log_root_path)<br/>(now absolute ✓)
    end
    
    Main->>Config: Set train_dir = log_root_path
    Main->>FS: Create directories
    Main->>FS: dump_yaml(env.yaml)
    Main->>FS: dump_yaml(agent.yaml)
    Main->>RLGames: Initialize runner with log_root_path
    
    Note over Main,RLGames: Ray and other integrations<br/>expect absolute paths
Loading

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@kellyguo11 kellyguo11 merged commit ed68089 into isaac-sim:main Nov 6, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report] rl_games workflow's log_root_path is not the absolute path when pbt is not used

5 participants